package com.sunsharing.wsdlcall.wsdl4j;

import com.sunsharing.common.utils.StringUtils;
import org.apache.axis.wsdl.gen.Parser;

import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 12-7-19
 * Time: 上午11:18
 * To change this template use File | Settings | File Templates.
 */
public class WsdlService {

    private String serviceId;
    private Parser wsdlParser;
    private String targetNameSpace;
    private String wsdl;
    private String methodName;
    private String portName;
    private List<WsdlOperatorElement> inputs = new ArrayList<WsdlOperatorElement>();
    private WsdlOperatorElement output;
    private QName qname;


    public String getServiceId() {
        return serviceId;
    }

    public String getTargetNameSpace() {
        return targetNameSpace;
    }

    public void setTargetNameSpace(String targetNameSpace) {
        this.targetNameSpace = targetNameSpace;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public void addInput(WsdlOperatorElement input)
    {
        inputs.add(input);
    }

    public List<WsdlOperatorElement> getInputs() {
        return inputs;
    }

    public void setInputs(List<WsdlOperatorElement> inputs) {
        this.inputs = inputs;
    }

    public WsdlOperatorElement getOutput() {
        return output;
    }

    public void setOutput(WsdlOperatorElement output) {
        this.output = output;
    }

    public String getRequest(String requestId)
    {
         if(StringUtils.isBlank(requestId))
         {
             requestId = "XM.GOV.TEST";
         }
         String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
                 "<Request>\n" +
                 "<SenderId>"+requestId+"</SenderId>\n" +
                 "<ServiceId>"+serviceId+"</ServiceId>\n" +
                 "<Inputs>\n";
         for(int i = 0;i<inputs.size();i++)
         {
             WsdlOperatorElement ele = inputs.get(i);
             str+=ele.getStandardInputStr();
         }
         str+="</Inputs>\n" +
         "</Request>\n";
        return str;
    }

    public Parser getWsdlParser() {
        return wsdlParser;
    }

    public void setWsdlParser(Parser wsdlParser) {
        this.wsdlParser = wsdlParser;
    }

    public QName getQname() {
        return qname;
    }

    public void setQname(QName qname) {
        this.qname = qname;
    }

    public String getPortName() {
        return portName;
    }

    public void setPortName(String portName) {
        this.portName = portName;
    }

    public String getWsdl() {
        return wsdl;
    }

    public void setWsdl(String wsdl) {
        this.wsdl = wsdl;
    }
}



